<?php
session_start();
?>
<?php
require "lib/db.php";
require "lib/case-function.php";
require "lib/status-function.php";
require "lib/priority-function.php";
require "lib/customer-function.php";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Edit Case</title>
<link rel="stylesheet" type="text/css" href="css/home.css">
<script type="text/javascript" src="js/jquery-1.11.2.min.js"></script>

<script>
	$(document).ready(function() {
			$("#case").css({"background-color":"#FFF",	
	"color":"#000"});
    });
</script>
<style>
	#content{
		width:40%;
		margin:50px auto;
		opacity:0.8;
	}
	
	input, textarea,select{
		width:100%;
	}
	
	#tdrequire{
		text-align:right;	
	}

</style>
</head>

<body>

<!--menu-->
<?php
require "menu.php";
?>

<?php
if(isset($_GET['caseid'])){
	$caseID = $_GET['caseid'];
	settype($caseID,"int");
	$case = mysql_fetch_array(getCaseByID($caseID));
}
?>

<!--content-->
<div id="content">
<form action="casecontroller.php" method="post">
<table width="100%" border="0" cellspacing="0">
   <tr>
 	<td></td>
    <td id="tdrequire"><span id="require">*</span>: required value</td>
  </tr>
  <tr>
    <td>Title<span id="require">*</span></td>
    <td><input name="txtTitle" type="text" value="<?php echo $case['Title']; ?>"></td>
  </tr>
  <tr>
    <td>Description</td>
    <td><textarea name="taDescription" cols="" rows="4"><?php echo $case['Description']; ?></textarea></td>
  </tr>
  <tr>
    <td>Status</td>
    <td>
    	<select name="cbStatus">
       		<?php
			$liststatus = getAllStatus();
			while($status = mysql_fetch_array($liststatus)){
			?>
        	<option <?php if($case['StatusID']==$status['StatusID']){echo 'selected="selected"';} ?>  value="<?php echo $status['StatusID']; ?>"><?php echo $status['Status']; ?></option>
            <?php
			}
			?>
        </select>
    </td>
  </tr>
  <tr>
    <td>Solution</td>
    <td><textarea name="taSolution" cols="" rows="4"><?php echo $case['Solution']; ?></textarea></td>
  </tr>
  <tr>
    <td>Case Month</td>
    <td>
    	<select disabled="true" name="cbCaseMonth">
        	<option <?php if($case['CaseMonth']==1){echo 'selected="selected"';} ?> value="1">January</option>
            <option <?php if($case['CaseMonth']==2){echo 'selected="selected"';} ?> value="2">February</option>
            <option <?php if($case['CaseMonth']==3){echo 'selected="selected"';} ?> value="3">March</option>
            <option <?php if($case['CaseMonth']==4){echo 'selected="selected"';} ?> value="4">April</option>
            <option <?php if($case['CaseMonth']==5){echo 'selected="selected"';} ?> value="5">May</option>
            <option <?php if($case['CaseMonth']==6){echo 'selected="selected"';} ?> value="6">June</option>
            <option <?php if($case['CaseMonth']==7){echo 'selected="selected"';} ?> value="7">July</option>
            <option <?php if($case['CaseMonth']==8){echo 'selected="selected"';} ?> value="8">August</option>
            <option <?php if($case['CaseMonth']==9){echo 'selected="selected"';} ?> value="9">September</option>
            <option <?php if($case['CaseMonth']==10){echo 'selected="selected"';} ?> value="10">October</option>
            <option <?php if($case['CaseMonth']==11){echo 'selected="selected"';} ?> value="11">November</option>
            <option <?php if($case['CaseMonth']==12){echo 'selected="selected"';} ?> value="12">December</option>
        </select>
    </td>
  </tr>
  <tr>
    <td>Case Year</td>
    <td>
    	<select disabled="true" name="cbCaseYear">
        	<option <?php if($case['CaseYear']==2013){echo 'selected="selected"';} ?> value="2013">2013</option>
            <option <?php if($case['CaseYear']==2014){echo 'selected="selected"';} ?> value="2014">2014</option>
        </select>
    </td>
  </tr>
  <tr>
    <td>Customer Name</td>
    <td>
    	<select disabled="true" name="cbCustomer">
       		<?php
			$listcustomer = getAllCustomer();
			while($customer = mysql_fetch_array($listcustomer)){
			?>
        	<option <?php if($case['CustomerID']==$customer['CustomerID']){echo 'selected="selected"';} ?>  value="<?php echo $customer['CustomerID']; ?>"><?php echo $customer['CustomerName']; ?></option>
            <?php
			}
			?>
        </select>
    </td>
  </tr>
  <tr>
    <td>Priority</td>
    <td>
    	<select disabled="true" name="cbPriority">
       		<?php
			$listpriority = getAllPriority();
			while($priority = mysql_fetch_array($listpriority)){
			?>
        	<option <?php if($case['PriorityID']==$priority['PriorityID']){echo 'selected="selected"';} ?> value="<?php echo $priority['PriorityID']; ?>"><?php echo $priority['Priority']; ?></option>
            <?php
			}
			?>
        </select>
    </td>
  </tr>
  <tr>
  	<td><input name="hfCaseID" type="hidden" value="<?php echo $caseID; ?>"></td>
    <td><input name="btnEditCase" type="submit" value="Edit Case"></td>
    </tr>
</table>

</form>

</div>

<!--footer-->
<?php
require "footer.php";
?>

</body>
</html>